<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
	</head>
	<body>
		<script>
			var arr = [1,1,2,2,3,3,4,4,5,5];
			//方法1
						
//新建一个临时数组
			var arr1 = [];
//遍历当前数组
			for(var i = 0;i < arr.length;i++){
//如果当前数组的第i个已经保存在临时数组,就跳过
				if(arr1.indexOf(arr[i])==-1){
//否则把当前数字push到临时数组中
					arr1.push(arr[i]);
				}
			}
			console.log(arr1);
			
			
			//方法2
			var arr2 = [];
			for(var i =0;i<arr.length;i++){
				if(!arr2.includes(arr[i])){
					arr2.push(arr[i]);
				}
			}
			console.log(arr2);
			
			
		</script>
		
	</body>
</html>
